package com.example.mybatisplus.model.dto;
import com.example.mybatisplus.mapper.StudentsMapper;
import com.example.mybatisplus.model.domain.Students;
import com.example.mybatisplus.model.domain.Violations;
import com.example.mybatisplus.service.StudentsService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class VioDetailDto {
    private String studentId;           // 学号
    private String violationType;       // 违纪种类
    private String violationCategory;   // 违纪行为摘要
    private LocalDateTime happenTime;   // 违纪发生时间
    private LocalDateTime effectiveTime;// 违纪生效时间
    private String result;
    private String publishmentDuration; // 处分时长
    private String operatorAid;            // 录入人
    private String vioId;


    public Violations toViolation(){
        Violations violations= new Violations();
        violations.setStudentId(studentId);
        violations.setViolationType(violationType);
        violations.setViolationCategory(violationCategory);
        violations.setHappenTime(happenTime);
        violations.setEffectiveTime(effectiveTime);
        violations.setEnterTime(LocalDateTime.now());
        int day=Integer.parseInt(publishmentDuration);
        violations.setPunishmentDuration(day);
        violations.setUnremindTime(effectiveTime.plusDays(day));
        violations.setVioId(vioId);
        violations.setResult(result);
        return violations;
    }
}
